
/*
'===============================================================================
'  Generated From - DAAB_DAL_NET2.vbgen
'  It is based on the DAAB from the November 2005 Enterprise Library
'  
'  This object is 'abstract' which means you need to inherit from it to be able
'  to instantiate it.  This is very easily done. You can override properties and
'  methods in your derived class, this allows you to regenerate this class at any
'  time and not worry about overwriting custom code. 
'
'  Custom DAL methods should be written into the inherited class.
' 
'  Version: 1.0
'  Date:	30/01/06
'  Summary: SelectOne, SelectAll, SelectAllWForeignKey, Insert, Update, Delete,
'  			DeleteAllWForeignKey.
'===============================================================================
*/
using System;
using System.Data;
using System.Data.Common;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;

namespace PlacementManager.DAL
{
    public abstract class _LinkApplicationPlacementPeriod_DAL
    {
		#region Members
		protected int _ApplicationPlacementPeriodId;
		protected int _ApplicationId;
		protected int _PlacementPeriodId;
		protected bool _IsActive;
		protected DateTime _DateCreated;
		protected string _CreatedBy;
		protected DateTime _DateUpdated;
		protected string _UpdatedBy;
		#endregion

		#region Properties
		
		public int ApplicationPlacementPeriodId
		{
			get	{ return _ApplicationPlacementPeriodId; }
			set	{ _ApplicationPlacementPeriodId = value; }
		}
		
		public int ApplicationId
		{
			get	{ return _ApplicationId; }
			set	{ _ApplicationId = value; }
		}
		
		public int PlacementPeriodId
		{
			get	{ return _PlacementPeriodId; }
			set	{ _PlacementPeriodId = value; }
		}
		
		public bool IsActive
		{
			get	{ return _IsActive; }
			set	{ _IsActive = value; }
		}
		
		public DateTime DateCreated
		{
			get	{ return _DateCreated; }
			set	{ _DateCreated = value; }
		}
		
		public string CreatedBy
		{
			get	{ return _CreatedBy; }
			set	{ _CreatedBy = value; }
		}
		
		public DateTime DateUpdated
		{
			get	{ return _DateUpdated; }
			set	{ _DateUpdated = value; }
		}
		
		public string UpdatedBy
		{
			get	{ return _UpdatedBy; }
			set	{ _UpdatedBy = value; }
		}
		
		#endregion

        //Constructor
        public _LinkApplicationPlacementPeriod_DAL()
        {

        }
		
		/// <summary>
		/// Purpose: SelectAll method. This method will Select all rows from the table.
		/// </summary>
		/// <returns></returns>
		public DataSet SelectAll()
        {
            // Create the Database object, using the default database service. The
            // default database service is determined through configuration.
            Database db = DatabaseFactory.CreateDatabase("PlacementsManager");

            string sqlCommand = "pr_LinkApplicationPlacementPeriod_DAL_SelectAll";
            DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);

            // Retrieve products from the specified category.
            db.AddInParameter(dbCommand, "ErrorCode", DbType.Int32, null);
		
            DataSet dsToReturn = null;
            dsToReturn = db.ExecuteDataSet(dbCommand);
            return dsToReturn;
        }
		
		/// <summary>
		/// Purpose: Select method. This method will Select one existing row from the database, based on the Primary Key.
		/// </summary>
		/// <returns></returns>
		public DataSet SelectOne()
        {
            // Create the Database object, using the default database service. The
            // default database service is determined through configuration.
            Database db = DatabaseFactory.CreateDatabase("PlacementsManager");

            string sqlCommand = "pr_LinkApplicationPlacementPeriod_DAL_SelectOne";
            DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);

			db.AddInParameter(dbCommand, "ApplicationPlacementPeriodId", DbType.Int32, _ApplicationPlacementPeriodId);

            db.AddInParameter(dbCommand, "ErrorCode", DbType.Int32, null);
		
            DataSet dsToReturn = null;
            dsToReturn = db.ExecuteDataSet(dbCommand);
            return dsToReturn;
        }
		
		/// <summary>
		/// Purpose: Select method for a foreign key. This method will Select one or more rows from the database, based on the Foreign Key 'ApplicationId'.
		/// </summary>
		/// <returns></returns>
		public DataSet SelectAllWApplicationId()
		{
			// Create the Database object, using the default database service. The
			// default database service is determined through configuration.
			Database db = DatabaseFactory.CreateDatabase("PlacementsManager");
			string sqlCommand = "pr_LinkApplicationPlacementPeriod_DAL_SelectAllWApplicationId";
			DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);
			db.AddInParameter(dbCommand, "ApplicationId", DbType.Int32, _ApplicationId);
			db.AddInParameter(dbCommand, "ErrorCode", DbType.Int32, null);
			DataSet dsToReturn = null;
			dsToReturn = db.ExecuteDataSet(dbCommand);
			return dsToReturn;
		}
/// <summary>
		/// Purpose: Select method for a foreign key. This method will Select one or more rows from the database, based on the Foreign Key 'PlacementPeriodId'.
		/// </summary>
		/// <returns></returns>
		public DataSet SelectAllWPlacementPeriodId()
		{
			// Create the Database object, using the default database service. The
			// default database service is determined through configuration.
			Database db = DatabaseFactory.CreateDatabase("PlacementsManager");
			string sqlCommand = "pr_LinkApplicationPlacementPeriod_DAL_SelectAllWPlacementPeriodId";
			DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);
			db.AddInParameter(dbCommand, "PlacementPeriodId", DbType.Int32, _PlacementPeriodId);
			db.AddInParameter(dbCommand, "ErrorCode", DbType.Int32, null);
			DataSet dsToReturn = null;
			dsToReturn = db.ExecuteDataSet(dbCommand);
			return dsToReturn;
		}

		/// <summary>
		/// Inserts the current instance data into the database.
		/// </summary>
		/// <returns></returns>
		public int Insert()
		{
			// Create the Database object, using the default database service. The
            // default database service is determined through configuration.
            Database db = DatabaseFactory.CreateDatabase("PlacementsManager");

            string sqlCommand = "pr_LinkApplicationPlacementPeriod_DAL_Insert";
            DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);

			// Add parameters
			db.AddInParameter(dbCommand,"ApplicationId", DbType.Int32, _ApplicationId);
			db.AddInParameter(dbCommand,"PlacementPeriodId", DbType.Int32, _PlacementPeriodId);
			db.AddInParameter(dbCommand,"IsActive", DbType.Boolean, _IsActive);
			db.AddInParameter(dbCommand,"DateCreated", DbType.DateTime, _DateCreated);
			db.AddInParameter(dbCommand,"CreatedBy", DbType.AnsiString, _CreatedBy);
			db.AddInParameter(dbCommand,"DateUpdated", DbType.DateTime, _DateUpdated);
			db.AddInParameter(dbCommand,"UpdatedBy", DbType.AnsiString, _UpdatedBy);
			db.AddOutParameter(dbCommand, "ApplicationPlacementPeriodId", DbType.Int32, 4);
			db.AddOutParameter(dbCommand, "ErrorCode", DbType.Int32, 4);

			db.ExecuteNonQuery(dbCommand);
			
			// Save output parameter values
			object param;
			param = db.GetParameterValue(dbCommand, "ApplicationPlacementPeriodId");
			if (param == DBNull.Value) return 0;
			_ApplicationPlacementPeriodId = (int)param;
			
			return _ApplicationPlacementPeriodId;
		}
	
		/// <summary>
		/// Purpose: Update method. This method will Update one existing row in the database.
		/// </summary>
		/// <returns></returns>
		public bool Update()
		{
			// Create the Database object, using the default database service. The
			// default database service is determined through configuration.
			Database db = DatabaseFactory.CreateDatabase("PlacementsManager");

			string sqlCommand = "pr_LinkApplicationPlacementPeriod_DAL_Update";
			DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);


			// Add parameters
			db.AddInParameter(dbCommand,"ApplicationPlacementPeriodId", DbType.Int32, _ApplicationPlacementPeriodId);
			db.AddInParameter(dbCommand,"ApplicationId", DbType.Int32, _ApplicationId);
			db.AddInParameter(dbCommand,"PlacementPeriodId", DbType.Int32, _PlacementPeriodId);
			db.AddInParameter(dbCommand,"IsActive", DbType.Boolean, _IsActive);
			db.AddInParameter(dbCommand,"DateCreated", DbType.DateTime, _DateCreated);
			db.AddInParameter(dbCommand,"CreatedBy", DbType.AnsiString, _CreatedBy);
			db.AddInParameter(dbCommand,"DateUpdated", DbType.DateTime, _DateUpdated);
			db.AddInParameter(dbCommand,"UpdatedBy", DbType.AnsiString, _UpdatedBy);


			db.AddInParameter(dbCommand, "ErrorCode", DbType.Int32, null);
			
			//try
			//{
				db.ExecuteNonQuery(dbCommand);
				return true;
			//}
			//catch
			//{
			//	return false;
			//}
		}
	
	
		/// <summary>
		/// Purpose: Delete method. This method will Delete one existing row in the database, based on the Primary Key.
		/// </summary>
		/// <returns></returns>
		public bool Delete()
        {
            // Create the Database object, using the default database service. The
            // default database service is determined through configuration.
            Database db = DatabaseFactory.CreateDatabase("PlacementsManager");

            string sqlCommand = "pr_LinkApplicationPlacementPeriod_DAL_Delete";
            DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);

			try
			{

			db.AddInParameter(dbCommand, "ApplicationPlacementPeriodId", DbType.Int32, _ApplicationPlacementPeriodId);

				db.AddInParameter(dbCommand, "ErrorCode", DbType.Int32, null);
				db.ExecuteNonQuery(dbCommand);
				return true;
			}
			catch
			{
				return false;
			}
        }
		/// <summary>
		/// Purpose: Delete method for a foreign key. This method will Delete one or more rows from the database, based on the Foreign Key 'ApplicationId'.
		/// </summary>
		/// <returns></returns>
		public bool DeleteAllWApplicationId()
		{
			// Create the Database object, using the default database service. The
			// default database service is determined through configuration.
			Database db = DatabaseFactory.CreateDatabase("PlacementsManager");
			string sqlCommand = "pr_LinkApplicationPlacementPeriod_DAL_DeleteAllWApplicationId";
			DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);
			try
			{
				db.AddInParameter(dbCommand, "ApplicationId", DbType.Int32, _ApplicationId);
				db.AddInParameter(dbCommand, "ErrorCode", DbType.Int32, null);
				db.ExecuteNonQuery(dbCommand);
				return true;
			}
			catch
			{
				return false;
			}
		}
/// <summary>
		/// Purpose: Delete method for a foreign key. This method will Delete one or more rows from the database, based on the Foreign Key 'PlacementPeriodId'.
		/// </summary>
		/// <returns></returns>
		public bool DeleteAllWPlacementPeriodId()
		{
			// Create the Database object, using the default database service. The
			// default database service is determined through configuration.
			Database db = DatabaseFactory.CreateDatabase("PlacementsManager");
			string sqlCommand = "pr_LinkApplicationPlacementPeriod_DAL_DeleteAllWPlacementPeriodId";
			DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);
			try
			{
				db.AddInParameter(dbCommand, "PlacementPeriodId", DbType.Int32, _PlacementPeriodId);
				db.AddInParameter(dbCommand, "ErrorCode", DbType.Int32, null);
				db.ExecuteNonQuery(dbCommand);
				return true;
			}
			catch
			{
				return false;
			}
		}

	
	}
}
